#include "task_sem.h"


int task_sem_init(task_sem_t *sem, unsigned int valeur){
	if(sem != NULL) {
	(*sem) = valeur;
	return 0;
	}
	else return -1;

}

int task_sem_post(task_sem_t * sem){
	if(sem != NULL){
		(*sem)++;
		return 0;
		}
	else return -1;
}

int task_sem_wait(task_sem_t * sem){
	if(sem != NULL){		
	while((*sem) == 0) task_cooperate();
	(*sem)--;
	return 0;
	}
 	else return -1;
}

int task_sem_destroy(task_sem_t * sem){
	if(sem != NULL){
	free(sem);
	return 0;
	}
	else return -1;
}




